<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
        <script type="text/javascript">

            var i = 1;
            function addp()
            {
                i++;
//                if (i < 10)
//                {
//                    i++;
//                }
//                else
//                {
//                    alert('can not add more items !');
//                    return;
//                }
                str = '<p id="p' + i + '">'
                		+'<input type="text" size="39" placeholder="<?= translate('PLASE_INPUT_ITEM') ?>"'
                		+' name="row[item][]" id="itemid' + i + '" class="autocomplete" table="type_object" autocomplete="off" >&nbsp;&nbsp;&nbsp;' 
                		+'<input type="text" size="8" placeholder="<?= translate('PLASE_INPUT_AMOUNT') ?>" name="row[amount][]" value="1" id="num' + i + '" >&nbsp;&nbsp;&nbsp;'
                		+'<select name="row[profession][]" id="profession'+i+'">'
                        +'<?php foreach ($professionlist as $m => $n) { ?>'
		                +	'<option value="<?= $m ?>" ><?= $n ?></option>'
		                +'<?php } ?>'
		            	+'</select>'
                		+'</p>';
                $("#add").append(str);
                autocomplete();
            }
            function removep()
            {
                if (i > 0)
                {
                    $("#p" + i).remove();
                    i--;
                }
            }
        </script>
    </head>
    <body>
        <?php include(VIEWPATH . 'common/main_header.php'); ?>
        <form action="" method="POST" id="rowForm">
            <table id="tb" width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
            	<tr><td><?= translate('CDKEY_GIFTBAG_ID') ?>:</td><td><input type="text" name="row[id]" id="id" size="25" /></td></tr>
                <tr><td><?= translate('CDKEY_GIFTBAG_NAME') ?>:</td><td><input type="text" name="row[name]" id="name" size="25" /></td></tr>
             <!-- <tr><td><?= translate('ACTIVITY_GIFTBAG_OBJECTICON') ?>:</td><td><input type="text" name="row[objecticon]" id="objecticon" size="25" /></td></tr>  -->
                <tr><td><?= translate('CDKEY_GIFTBAG_DESCRIBE') ?>:</td><td><textarea name="row[describe]" id="describe" cols="50" rows="5"></textarea></td></tr>
                <tr><td><?= translate('ITEM') ?>:</td>
                    <td id="add">
                        <p id="p">
                        
                        	<input type="button" onclick="addp()" value="<?= translate('ADD_ONE') ?>" />
                            <input type="button" onclick="removep()" value="<?= translate('REMOVE_ONE') ?>" /></p>
                            
                            <input type="text" size="39" placeholder="<?= translate('PLASE_INPUT_ITEM') ?>" name="row[item][]" id="itemid0" class="autocomplete" table="type_object" />&nbsp;&nbsp;
                            <input type="text" size="8"  placeholder="<?= translate('PLASE_INPUT_AMOUNT') ?>" name="row[amount][]" id="num0" value = '1' />&nbsp;&nbsp;
                            <select name="row[profession][]" id="profession0">
	                            <?php foreach ($professionlist as $m => $n) { ?>
	                            	<option value="<?= $m ?>" ><?= $n ?></option>
	                        	<?php } ?>
                        	</select>&nbsp;&nbsp;                        	
                            
                    </td>
                </tr>
                <tr><td></td><td><input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/> <input type="reset" value="<?= translate('RESET') ?>" id="reset"/></td></tr>
            </table>
        </form>
        <script type="text/javascript">
            SG.init("core.form", function() {
                $.formValidator.initConfig({formid: "#rowForm", submitonce: true});
                $("#id").formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                $("#name").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#icon").formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                //$("#num0").formValidator({empty: false, defaultvalue: '<?= translate('AREA_FORM_INPUT_OPENTIME') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
            });
        </script>
    </body>
</html>
